@startuml UC02_sequence
!theme plain
hide footbox
skinparam sequenceMessageAlign center
skinparam responseMessageBelowArrow true
skinparam BoxPadding 10
autonumber

title UC-02 - Cruise forward while cleaning\n(sequence diagram)

actor "Home user\n(beneficiary)" as User
participant "Obstacle sensors" as Obs
participant "Dust sensor" as Dust
box "Roomba RVC control software\n(inside the SSD black box)" #E8F4FF
  participant "perception:\nObstaclePerceptionContext" as Perception
  participant "navigation:\nNavigationAndEscapeCoordinator" as Nav
  participant "cleaning:\nSurfaceCleaningController" as Clean
end box
participant "Wheel motors\n(left, right)" as Motors
participant "Cleaning hardware" as CleanHW

note over User, Clean : after UC-01

loop [cruise cycle until stop or other UC]
  alt [typical]
    Obs -> Perception : ObstacleStateChanged(frame)
    Perception -> Nav : FusedObstacleSnapshot(forwardSafe)
    Nav -> Motors : MotionCommand(forward)
    Clean -> CleanHW : CleaningCommand(normal)
  else [A1 dust boost concurrent]
    Obs -> Perception : ObstacleStateChanged(frame)
    Perception -> Nav : FusedObstacleSnapshot(forwardSafe)
    Nav -> Motors : MotionCommand(forward)
    Dust -> Clean : DustSignalUpdated(aboveThreshold)
    Clean -> CleanHW : CleaningCommand(boost)
  else [E1 stale or missing obstacle data]
    Obs -> Perception : ObstacleStateChanged(invalidOrStale)
    Perception -> Nav : FusedObstacleSnapshot(invalid)
    note over Perception, Nav : next: UC-08
  end
end

note over Obs, CleanHW : repeat until UC-03, UC-04, UC-05, or stop

@enduml
